#!/usr/bin/env python3
import sys
import os
import subprocess

# 将项目目录添加到 Python 路径
project_dir = "/home/jianglong/TradingAgents copy"
if project_dir not in sys.path:
    sys.path.insert(0, project_dir)

# 设置环境变量
os.environ['PYTHONPATH'] = f"{os.environ.get('PYTHONPATH', '')}:{project_dir}"

# 加载环境变量
def load_env():
    """加载环境变量"""
    try:
        from dotenv import load_dotenv
        load_dotenv()
    except ImportError:
        # 如果没有 python-dotenv，手动加载环境变量
        env_file = os.path.join(project_dir, '.env')
        if os.path.exists(env_file):
            with open(env_file, 'r') as f:
                for line in f:
                    if line.strip() and not line.startswith('#'):
                        key, value = line.strip().split('=', 1)
                        os.environ[key] = value

# 运行主程序
if __name__ == "__main__":
    # 先加载环境变量
    load_env()
    
    # 然后运行主程序
    from cli.main import analyze
    analyze() 